<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        <p>{{msg | dateMoment(type)}}</p>
    </div>

    <div id="app2">
        <p>{{msg | dateMoment(type)}}</p>
    </div>
</body>
<script src="../js/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script>
    Vue.filter('dateMoment', (date,type="YYYY-MM-DD HH:mm:ss")=>{
        return  moment(date).format(type);
    });


    var vm = new Vue({
        el:"#app",
        data:{
            msg:new Date(),
            type:"YYYY-MM-DD HH xxx "
        },
        /*filters:{
            dateMoment(date,type="YYYY-MM-DD HH:mm:ss"){
                return  moment(date).format(type);
            }
        }*/
    });

    var vm = new Vue({
        el:"#app2",
        data:{
            msg:new Date(),
            type:"YYYY-MM-DD HH xxx "
        },
        /*filters:{
            dateMoment(date,type="YYYY-MM-DD HH:mm:ss"){
                return  moment(date).format(type);
            }
        }*/
    });
</script>
</html>